{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "import sympy as sym\n",
    "import pyperclip"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "beta1, beta2, E = sym.symbols(\"\\\\beta_1, \\\\beta_2, E\")\n",
    "Jx1, Jx2, Jy1, Jy2 = sym.symbols(\"J_{x1}, J_{x2}, J_{y1}, J_{y2}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "f1 = (Jx1 / beta1 + Jx2 / beta2 + Jy1/beta1/beta2 + Jy2)\n",
    "f2 = (Jx2 * beta1 + Jx1 * beta2 + Jy2 * beta1 * beta2 + Jy1)\n",
    "f = sym.expand(f1 * f2)\n",
    "pyperclip.copy(sym.printing.latex(f))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "two = sym.Number(2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "g1 = (Jx1 * beta1 ** (-1/two) * beta2 ** (1/two) \n",
    "      + Jx2 * beta1 ** (1/two) * beta2 ** (-1/two) \n",
    "      + Jy1 * beta1 ** (-1/two) * beta2 ** (-1/two)\n",
    "      + Jy2 * beta1 ** (1/two) * beta2 ** (1/two))\n",
    "g = sym.expand(g1 * g1)\n",
    "pyperclip.copy(sym.printing.latex(g))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n"
     ]
    }
   ],
   "source": [
    "print(sym.simplify(f-g))"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "base",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.16"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
